﻿using Cms.Core.Data.Mapping;
using Cms.Core.Data.Model;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;


namespace Cms.Core.Data.Configurations
{
    public class AuditLogsConfigurations :EntityMappingConfiguration<AuditLog>
    {
    

        public override void Map(EntityTypeBuilder<AuditLog> builder)
        {
            builder.HasKey(o => o.Id);
            builder.Property(b => b.UserId).IsRequired(false);
            builder.Property(b => b.ServiceName).HasColumnType("nchar(1000)").IsRequired(true);
            builder.Property(b => b.MethodName).HasColumnType("nchar(1000)").IsRequired(true);
            builder.Property(b => b.Parameters).HasColumnType("nvarchar(MAX)").IsRequired(false);
            builder.Property(b => b.ExecutionTime).HasColumnType("datetime").IsRequired(false);
            builder.Property(b => b.ExecutionDuration).HasColumnType("bigint").IsRequired(false);
            builder.Property(b => b.ClientIPAddress).HasColumnType("nchar(15)").IsRequired(false);
            builder.Property(b => b.ClientName).HasColumnType("nvarchar(50)").IsRequired(false);
            builder.Property(b => b.BrowserInfo).HasColumnType("nchar(1000)").IsRequired(false);
            builder.Property(b => b.DisplayName).HasColumnType("nvarchar(100)").IsRequired(false);
            builder.Property(b => b.ExceptionInfo).HasColumnType("nvarchar(MAX)").IsRequired(false);
            builder.Ignore(b => b.CreateUserId);
            builder.Ignore(b => b.IsDelete);
            builder.Ignore(b => b.ModifiedUserId);
            builder.Ignore(b => b.ModifiedTime);
            builder.Ignore(b => b.CreateTime);
            builder.ToTable("AuditLog");
        }

     
    }
}
